<?php

namespace App\Api\Middleware;

use Closure;
use Illuminate\Http\Request;

/**
 * 响应返回的格式，设置为 application/json, 遇到的所有报错 Laravel 会默认处理为 JSON 格式
 * Class ForceJson
 * @package App\Api\Middleware
 */
class ForceJson
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $request->headers->set('accept', 'application/json');
        return $next($request);
    }
}
